<template>
	<view class="page">
		<view v-for="(result,index) in results" :key="index" :data-id="index" @tap="openinfo">
			<testResult 
			:name="result.name"
			:hospital="result.place"
			:number="result.recognizeCode"
			:time="result.time"
			:items="result.items"
			/>			<!-- :id="result.id" -->
		</view>
	</view>
</template>

<script>
	import testResult from "~@/components/testResult.vue"
	import request from '~@/utils/api.js'
	export default {
		components:{
			testResult
		},
		data() {
			return {
				// name:'胡图图',
				results:[],
				// results:[
				// 	{
				// 	hospital:'成都理工大学校医院',
				// 	number:'1111',
				// 	time:'2022-08-23 00:13:16',
				// 	items:[]
				// 	}
				// ]
			}
		},
		onLoad() {
			let page= getCurrentPages()
			console.log("ListPage:",page);
			let that = this
			let userInfo = uni.getStorageSync('userInfo')
			let list= []
			request('/test/List',{},'GET').then(resp=>{
				list = resp.data;
				// console.log("list:",list);
				list.forEach((item)=>{
					//处理data,转换为items数组
					let items = JSON.parse(item.data);
					// console.log(items);
					item["items"]=items;//转换结果加入list
					that.results.push(item);
				})
				console.log("list:",list);
				uni.setStorageSync("testList",list)
			})
		},
		methods: {
			openinfo(e){
				let id=e.currentTarget.dataset.id;
				uni.navigateTo({
					url:'/pages/index/test/detail'+'?id='+id
				});
			}
		}
	}
</script>>
	
<style>
	
</style>
